package com.zhoujian.Prototype.DeepCopy;

import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Data

public class Main {
    public static void main(String[] args) {
        PromotionEvent promotionEvent = new PromotionEvent();
        promotionEvent.setStartDate(new Date());
        PromotionRule promotionRule = new PromotionRule();

        promotionRule.setType("折扣");
        promotionRule.setDiscount(0.9);
        Product product = new Product();
        promotionRule.setProduct(product);
//        List<PromotionRule> rules = new ArrayList<>();
//        rules.add(promotionRule);
//        promotionEvent.setRules(rules);
        promotionEvent.setRules(List.of(promotionRule));

        //深拷贝
        PromotionEvent clonePromotionEvent = promotionEvent.clone();
        System.out.println(clonePromotionEvent.getRules().get(0).getProduct() == product);
    }
}
